package cn.com.utt.unms.controller;

import java.security.Principal;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import cn.com.utt.common.vo.RestResult;
import cn.com.utt.common.vo.User;
import cn.com.utt.unms.pojo.WxMarketing;
import cn.com.utt.unms.service.WxMarketingService;

@RestController
@RequestMapping("v1/wxMarketing")
public class WxMarketingController {

	@Autowired
	private WxMarketingService wxMarketingService;

	@RequestMapping(value = "/info", method = { RequestMethod.GET })
	public Map<String, Object> info(Principal principal) {

		Authentication authentication = (Authentication) principal;
		User user = (User) authentication.getPrincipal();

		RestResult result = new RestResult();
//		WxMarketing wxMarketing = wxMarketingService.queryMarketingByCfgId(user.getCfgId());
//		result.put("wxMarketing", wxMarketing);

		return result.toJsonObject();
	}

	@RequestMapping(value = "/info", method = { RequestMethod.POST }, consumes = "application/json")
	public Map<String, Object> update(@RequestBody WxMarketing wxMarketing, Principal principal) {

//		Authentication authentication = (Authentication) principal;
//		User user = (User) authentication.getPrincipal();
//
//		wxMarketingService.updateMarketingByCfgId(wxMarketing, user.getCfgId());
//
		RestResult result = new RestResult();
		return result.toJsonObject();
	}

}